package com.desk.copyfile.main;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;


import java.util.HashMap;
import java.util.Map;

@Component
@ConfigurationProperties(prefix = "my.property")
public class MyConfigProperties {

    private String targetPath;

    private Map<String, optionsSet> optionsMap;

    public String getTargetPath() {
        return targetPath;
    }

    public void setTargetPath(String destinationPath) {
        this.targetPath = destinationPath;
    }

    public Map<String, optionsSet> getOptionsMap() {
        return optionsMap;
    }

    public void setOptionsMap(Map<String, optionsSet> optionsMap) {
        this.optionsMap = optionsMap;
    }

    public Map<String,String[]> getAllOptionsMap(){
        HashMap<String,String[]> allOptionsMap = new HashMap<>();
        Map<String, MyConfigProperties.optionsSet> optionsMap = this.getOptionsMap();
        for (MyConfigProperties.optionsSet value : optionsMap.values()) {
            allOptionsMap.put(value.getName(),new String[]{value.getPath(),value.getTarget()});
        }
        return allOptionsMap;
    }

    public static class optionsSet {
        private String path;
        private String name;
        private String target;
        private boolean selected;


        public String getPath() {
            return path;
        }

        public void setPath(String path) {
            this.path = path;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getTarget() {
            return target;
        }

        public void setTarget(String target) {
            this.target = target;
        }

        public boolean isSelected() {
            return selected;
        }

        public void setSelected(boolean selected) {
            this.selected = selected;
        }
    }
}